<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>随机图片</title>
      <style>
         img {
             display: block;
             margin: 0 auto;
             width: 300px;
             height: 200px;
         }
      </style>
   </head>
   <body>
      <img src="./images/1.webp" alt="哈哈">
      <script>
         function getRandom(min = 0, max = 0){
            return Math.floor(Math.random() * (max - min + 1) + min)
         }
         const img = document.querySelector('img')
         let random = getRandom(1, 6)
         img.src = `./images/${random}.webp`
      </script>
   </body>
</html>